if statement
def max_num(num1,num2,num3):
print('this is max_num1')
return(max(num1,num2,num3))
print(max_num(2,3,108))
def max_num(num1,num2,num3):
print('this is max num2')
if num1>=num2 and num1>=num3:
return num1
elif num2>=num1 and num2>=num3:
return num2
else:
return num3
print(max_num(2,111,111111))
進階計算機(可加減乘除運算)
num1 = float(input("請輸入第一個數字: "))
op = input("請輸入運算符號: ")
num2 = float(input("請輸入第二個數字: "))
if op=="+":
print(num1+num2)
elif op=="-":
print(num1-num2)
elif op=="*":
print(num1*num2)
elif op=="/":
print(num1/num2)
else:
priint("不支援的運算")